﻿using System.Data;
using System.Data.SqlClient;

namespace MyWeb.Data
{
    public class OrderDetailController : SqlDataProvider
    {
        #region [OrderDetail_GetByAll]

        public DataTable OrderDetail_GetByAll()
        {
            return GetDataTable("sp_OrderDetail_GetByAll");
        }

        #endregion

        #region [OrderDetail_GetById]

        public DataTable OrderDetail_GetById(int id)
        {
            var p1 = new SqlParameter("@id", id);
            return GetDataTable("sp_OrderDetail_GetById", p1);
        }

        #endregion

        #region [OrderDetail_Insert]

        public void OrderDetail_Insert(OrderDetailInfo orderDetail)
        {
            var p1 = new SqlParameter("@Order_Id", orderDetail.Order_Id);
            var p2 = new SqlParameter("@Product_Id", orderDetail.Product_Id);
            var p3 = new SqlParameter("@Quantity", orderDetail.Quantity);
            ExecuteStoreProcedure("sp_OrderDetail_Insert", p1, p2, p3);
        }

        #endregion

        #region [OrderDetail_Update]

        public void OrderDetail_Update(OrderDetailInfo orderDetail)
        {
            var p0 = new SqlParameter("@Id", orderDetail.Id);
            var p1 = new SqlParameter("@Order_Id", orderDetail.Order_Id);
            var p2 = new SqlParameter("@Product_Id", orderDetail.Product_Id);
            var p3 = new SqlParameter("@Quantity", orderDetail.Quantity);
            ExecuteStoreProcedure("OrderDetail_Update", p0, p1, p2, p3);
        }

        #endregion

        #region [OrderDetail_Delete]

        public void OrderDetail_Delete(int id)
        {
            var p0 = new SqlParameter("@Id", id);
            ExecuteStoreProcedure("OrderDetail_Delete", p0);
        }

        #endregion
    }
}